package com.listeningframework.boot.codegen.constants;

import org.apache.commons.lang3.StringUtils;

/**
 * 类后缀
 */
public enum Templates {
    /**
     * Controller模板
     */
    CONTROLLER("Controller", ".java", "controller.ftl"),
    /**
     * Service模板
     */
    SERVICE("Service", ".java", "service.ftl"),
    /**
     * DAO模板
     */
    DAO("Repository", ".java", "repository.ftl"),
    /**
     * DTO模板
     */
    DOMAIN("DTO", ".java", "model.ftl"),
    /**
     * Entity模板
     */
    ENTITY("Entity", ".java", "entity.ftl"),
    /**
     * Mapper模板
     */
    MAPPER("Mapper", ".xml", "mapper.ftl");

    private String suffix;
    private String fileSuffix;
    private String template;

    private Templates(String suffix, String fileSuffix, String template) {
        this.suffix = suffix;
        this.fileSuffix = fileSuffix;
        this.template = template;
    }

    public String getSuffix() {
        return suffix;
    }

    public String getFileSuffix() {
        return fileSuffix;
    }

    public boolean isMapper() {
        return StringUtils.equalsIgnoreCase(this.getSuffix(), MAPPER.getSuffix());
    }

    public boolean isController() {
        return StringUtils.equalsIgnoreCase(this.getSuffix(), CONTROLLER.getSuffix());
    }

    public boolean isService() {
        return StringUtils.equalsIgnoreCase(this.getSuffix(), SERVICE.getSuffix());
    }

    public boolean isDao() {
        return StringUtils.equalsIgnoreCase(this.getSuffix(), DAO.getSuffix());
    }

    public boolean isEntity() {
        return StringUtils.equalsIgnoreCase(this.getSuffix(), ENTITY.getSuffix());
    }

    public boolean isDomain() {
        return StringUtils.equalsIgnoreCase(this.getSuffix(), DOMAIN.getSuffix());
    }

    public String getTemplate() {
        return template;
    }
}
